<?php
class Frmcreator_Model_DbTable_Options extends Engine_Db_Table
{
    protected $_rowClass = 'Frmcreator_Model_Option';
    
    public function removeOptions($form_id){
        $select     = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
                        ->setIntegrityCheck(false)
                        ->joinLeft('engine4_frmcreator_elements', 'engine4_frmcreator_elements.element_id = engine4_frmcreator_options.element_id', array())
                        ->where('form_id = ?', $form_id);

        $options   =  $this->fetchAll($select)->toArray();
        
        //remove options 
        foreach($options as $opt){
            $this->delete($this->getAdapter()->quoteInto('option_id = ?', $opt['option_id']));
        }
        
    }

}
